package org.jiopi.ibean.module.server.jiopi.rmi;

import java.rmi.RemoteException;

import org.jiopi.ibean.remote.rmi.RemoteCentralConsoleRMI;


public class IbeanRemoteCentralConsoleRMI implements RemoteCentralConsoleRMI {
	
	private final org.jiopi.remote.RemoteCentralConsole _rcc;
	private ClassLoader _contextClassLoader = null;
	
	public IbeanRemoteCentralConsoleRMI(org.jiopi.remote.RemoteCentralConsole rcc){
		this._rcc = rcc;
	}
	
	public void setContextClassLoader(ClassLoader contextClassLoader){
		_contextClassLoader = contextClassLoader;
	}

	@Override
	public Object methodCallStrict(String containerID,String moduleName,String compatibleVersion,String controlPanelName,String methodName,Class<?>[] parameterTypes,Object... args) {
		if(_contextClassLoader != null) Thread.currentThread().setContextClassLoader(_contextClassLoader);
		return _rcc.methodCallStrict(containerID, moduleName, compatibleVersion, controlPanelName, methodName,null, parameterTypes, args);
	}

	@Override
	public Object methodCall(String containerID, String moduleName,
			String compatibleVersion, String controlPanelName,
			String methodName, Object... args)
			throws RemoteException {
		if(_contextClassLoader != null) Thread.currentThread().setContextClassLoader(_contextClassLoader);
		return _rcc.methodCall(containerID, moduleName, compatibleVersion, controlPanelName, methodName, null, args);
	}

}
